package com.mytijian.task.zookeeper;

import com.mytijian.task.zookeeper.path.NodePath;

public class NodeService implements InitService{
    private ZookeeperRegistryCenter registryCenter;
    private Integer nodePort;
    public NodeService(ZookeeperRegistryCenter registryCenter, Integer nodePort) {
        this.registryCenter = registryCenter;
        this.nodePort = nodePort;
    }
    @Override
    public void init() {
        // 初始化节点信息
        registryCenter.persistEphemeral(getNodePath(), "");
    }

    private String getNodePath() {
        return NodePath.getNodeLocalIpAndPort(nodePort);
    }

}
